from selenium import webdriver
from selenium.webdriver.common.by import By
import os
import time

driver = webdriver.Chrome()
url = 'file:///' + os.path.abspath('html') + '/注册实例.html'
driver.get(url)

# # 点击账号框输入账号
time.sleep(2)
user = driver.find_element(By.ID, 'user').send_keys('12345')
# 点击密码框输入密码
time.sleep(2)
password = driver.find_element(By.ID, 'password').send_keys('123456')
# 点击电话号码框输入号码
time.sleep(2)
tel = driver.find_element(By.ID, 'tel').send_keys('1234567')
# 点击电子邮件框输入电子邮箱
time.sleep(2)
email = driver.find_element(By.ID, 'email').send_keys('1234567@qq.com')
# 点击注册用户
time.sleep(2)
btn = driver.find_element(By.XPATH, '//*[@id="zc"]/fieldset/button')
btn.click()

# TODO 会员注册A
driver.switch_to.frame('idframe1')
zca = driver.find_element(By.ID, "userA")
# # 点击账号框输入账号
userA = driver.find_element(By.ID, "userA").send_keys('12345')
time.sleep(2)
# 点击密码框输入密码
passwordA = driver.find_element(By.ID, "passwordA").send_keys('123456')
time.sleep(2)
# 点击电话号码框输入号码
telA = driver.find_element(By.ID, "telA").send_keys("1234567")
time.sleep(2)
# 点击电子邮件框输入电子邮箱
emailA = driver.find_element(By.ID, "emailA").send_keys('1234567@qq.com')
time.sleep(2)
# 点击注册用户
btnA = driver.find_element(By.XPATH, '//*[@id="zc"]/fieldset/button')
btnA.click()

# TODO 会员注册B
time.sleep(2)
driver.switch_to.default_content()
driver.switch_to.frame('myframe2')
zcb = driver.find_element(By.ID, 'userB')
# 点击账号框输入账号
userB = driver.find_element(By.ID, "userB").send_keys('12345')
time.sleep(2)
# 点击密码框输入密码
passwordB = driver.find_element(By.ID, "passwordB").send_keys('123456')
time.sleep(2)
# 点击电话号码框输入号码
telB = driver.find_element(By.ID, "telB").send_keys("1234567")
time.sleep(2)
# 点击电子邮件框输入电子邮箱
emailB = driver.find_element(By.ID, "emailB").send_keys('1234567@qq.com')
time.sleep(2)
# 点击注册用户
btnB = driver.find_element(By.XPATH, '//*[@id="zc"]/fieldset/button')
btnB.click()

time.sleep(2)
driver.quit()
